﻿using System;
using System.ComponentModel;

namespace HalconDotNet
{
	/// <summary>Represents an instance of a Dictionary.</summary>
	// Token: 0x02000031 RID: 49
	public class HDict : HHandle
	{
		// Token: 0x06000478 RID: 1144 RVA: 0x0001B1AC File Offset: 0x000193AC
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HDict(IntPtr handle) : base(handle)
		{
			this.AssertSemType();
		}

		// Token: 0x06000479 RID: 1145 RVA: 0x0001B1BB File Offset: 0x000193BB
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HDict(HHandle handle) : base(handle)
		{
			this.AssertSemType();
		}

		// Token: 0x0600047A RID: 1146 RVA: 0x0001B1CA File Offset: 0x000193CA
		private void AssertSemType()
		{
			base.AssertSemType("dict");
		}

		// Token: 0x0600047B RID: 1147 RVA: 0x0001B1D7 File Offset: 0x000193D7
		internal static int LoadNew(IntPtr proc, int parIndex, int err, out HDict obj)
		{
			obj = new HDict(HHandleBase.UNDEF);
			return obj.Load(proc, parIndex, err);
		}

		// Token: 0x0600047C RID: 1148 RVA: 0x0001B1F0 File Offset: 0x000193F0
		internal static int LoadNew(IntPtr proc, int parIndex, int err, out HDict[] obj)
		{
			HTuple htuple;
			err = HTuple.LoadNew(proc, parIndex, err, out htuple);
			obj = new HDict[htuple.Length];
			for (int i = 0; i < htuple.Length; i++)
			{
				obj[i] = new HDict(HalconAPI.IsLegacyHandleMode() ? htuple[i].IP : htuple[i].H);
			}
			htuple.Dispose();
			return err;
		}

		/// <summary>
		///   Create a new empty dictionary.
		///   Modified instance represents: Handle of the newly created dictionary.
		/// </summary>
		// Token: 0x0600047D RID: 1149 RVA: 0x0001B260 File Offset: 0x00019460
		public HDict()
		{
			IntPtr proc = HalconAPI.PreCall(2149);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Read a dictionary from a file.
		///   Modified instance represents: Dictionary handle.
		/// </summary>
		/// <param name="fileName">File name.</param>
		/// <param name="genParamName">Name of the generic parameter. Default: []</param>
		/// <param name="genParamValue">Value of the generic parameter. Default: []</param>
		// Token: 0x0600047E RID: 1150 RVA: 0x0001B2A4 File Offset: 0x000194A4
		public HDict(string fileName, HTuple genParamName, HTuple genParamValue)
		{
			IntPtr proc = HalconAPI.PreCall(2162);
			HalconAPI.StoreS(proc, 0, fileName);
			HalconAPI.Store(proc, 1, genParamName);
			HalconAPI.Store(proc, 2, genParamValue);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(genParamName);
			HalconAPI.UnpinTuple(genParamValue);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Read a dictionary from a file.
		///   Modified instance represents: Dictionary handle.
		/// </summary>
		/// <param name="fileName">File name.</param>
		/// <param name="genParamName">Name of the generic parameter. Default: []</param>
		/// <param name="genParamValue">Value of the generic parameter. Default: []</param>
		// Token: 0x0600047F RID: 1151 RVA: 0x0001B30C File Offset: 0x0001950C
		public HDict(string fileName, string genParamName, string genParamValue)
		{
			IntPtr proc = HalconAPI.PreCall(2162);
			HalconAPI.StoreS(proc, 0, fileName);
			HalconAPI.StoreS(proc, 1, genParamName);
			HalconAPI.StoreS(proc, 2, genParamValue);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Copy a dictionary.
		///   Instance represents: Dictionary handle.
		/// </summary>
		/// <param name="genParamName">Name of the generic parameter. Default: []</param>
		/// <param name="genParamValue">Value of the generic parameter. Default: []</param>
		/// <returns>Copied dictionary handle.</returns>
		// Token: 0x06000480 RID: 1152 RVA: 0x0001B368 File Offset: 0x00019568
		public HDict CopyDict(HTuple genParamName, HTuple genParamValue)
		{
			IntPtr proc = HalconAPI.PreCall(2148);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, genParamName);
			HalconAPI.Store(proc, 2, genParamValue);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(genParamName);
			HalconAPI.UnpinTuple(genParamValue);
			HDict result;
			num = HDict.LoadNew(proc, 0, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}

		/// <summary>
		///   Copy a dictionary.
		///   Instance represents: Dictionary handle.
		/// </summary>
		/// <param name="genParamName">Name of the generic parameter. Default: []</param>
		/// <param name="genParamValue">Value of the generic parameter. Default: []</param>
		/// <returns>Copied dictionary handle.</returns>
		// Token: 0x06000481 RID: 1153 RVA: 0x0001B3CC File Offset: 0x000195CC
		public HDict CopyDict(string genParamName, string genParamValue)
		{
			IntPtr proc = HalconAPI.PreCall(2148);
			base.Store(proc, 0);
			HalconAPI.StoreS(proc, 1, genParamName);
			HalconAPI.StoreS(proc, 2, genParamValue);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HDict result;
			num = HDict.LoadNew(proc, 0, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}

		/// <summary>
		///   Create a new empty dictionary.
		///   Modified instance represents: Handle of the newly created dictionary.
		/// </summary>
		// Token: 0x06000482 RID: 1154 RVA: 0x0001B424 File Offset: 0x00019624
		public void CreateDict()
		{
			this.Dispose();
			IntPtr proc = HalconAPI.PreCall(2149);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Retrieve an object associated with the key from the dictionary.
		///   Instance represents: Dictionary handle.
		/// </summary>
		/// <param name="key">Key string.</param>
		/// <returns>Object value retrieved from the dictionary.</returns>
		// Token: 0x06000483 RID: 1155 RVA: 0x0001B468 File Offset: 0x00019668
		public HObject GetDictObject(HTuple key)
		{
			IntPtr proc = HalconAPI.PreCall(2153);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, key);
			HalconAPI.InitOCT(proc, 1);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(key);
			HObject result;
			num = HObject.LoadNew(proc, 1, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}

		/// <summary>
		///   Retrieve an object associated with the key from the dictionary.
		///   Instance represents: Dictionary handle.
		/// </summary>
		/// <param name="key">Key string.</param>
		/// <returns>Object value retrieved from the dictionary.</returns>
		// Token: 0x06000484 RID: 1156 RVA: 0x0001B4C0 File Offset: 0x000196C0
		public HObject GetDictObject(string key)
		{
			IntPtr proc = HalconAPI.PreCall(2153);
			base.Store(proc, 0);
			HalconAPI.StoreS(proc, 1, key);
			HalconAPI.InitOCT(proc, 1);
			int num = HalconAPI.CallProcedure(proc);
			HObject result;
			num = HObject.LoadNew(proc, 1, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}

		/// <summary>
		///   Query dictionary parameters or information about a dictionary.
		///   Instance represents: Dictionary handle.
		/// </summary>
		/// <param name="genParamName">Names of the dictionary parameters or info queries. Default: "keys"</param>
		/// <param name="key">Dictionary keys the parameter/query should be applied to (empty for GenParamName = 'keys').</param>
		/// <returns>Values of the dictionary parameters or info queries.</returns>
		// Token: 0x06000485 RID: 1157 RVA: 0x0001B510 File Offset: 0x00019710
		public HTuple GetDictParam(string genParamName, HTuple key)
		{
			IntPtr proc = HalconAPI.PreCall(2154);
			base.Store(proc, 0);
			HalconAPI.StoreS(proc, 1, genParamName);
			HalconAPI.Store(proc, 2, key);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(key);
			HTuple result;
			num = HTuple.LoadNew(proc, 0, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}

		/// <summary>
		///   Query dictionary parameters or information about a dictionary.
		///   Instance represents: Dictionary handle.
		/// </summary>
		/// <param name="genParamName">Names of the dictionary parameters or info queries. Default: "keys"</param>
		/// <param name="key">Dictionary keys the parameter/query should be applied to (empty for GenParamName = 'keys').</param>
		/// <returns>Values of the dictionary parameters or info queries.</returns>
		// Token: 0x06000486 RID: 1158 RVA: 0x0001B570 File Offset: 0x00019770
		public HTuple GetDictParam(string genParamName, string key)
		{
			IntPtr proc = HalconAPI.PreCall(2154);
			base.Store(proc, 0);
			HalconAPI.StoreS(proc, 1, genParamName);
			HalconAPI.StoreS(proc, 2, key);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HTuple result;
			num = HTuple.LoadNew(proc, 0, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}

		/// <summary>
		///   Retrieve a tuple associated with the key from the dictionary.
		///   Instance represents: Dictionary handle.
		/// </summary>
		/// <param name="key">Key string.</param>
		/// <returns>Tuple value retrieved from the dictionary.</returns>
		// Token: 0x06000487 RID: 1159 RVA: 0x0001B5C8 File Offset: 0x000197C8
		public HTuple GetDictTuple(HTuple key)
		{
			IntPtr proc = HalconAPI.PreCall(2155);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, key);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(key);
			HTuple result;
			num = HTuple.LoadNew(proc, 0, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}

		/// <summary>
		///   Retrieve a tuple associated with the key from the dictionary.
		///   Instance represents: Dictionary handle.
		/// </summary>
		/// <param name="key">Key string.</param>
		/// <returns>Tuple value retrieved from the dictionary.</returns>
		// Token: 0x06000488 RID: 1160 RVA: 0x0001B620 File Offset: 0x00019820
		public HTuple GetDictTuple(string key)
		{
			IntPtr proc = HalconAPI.PreCall(2155);
			base.Store(proc, 0);
			HalconAPI.StoreS(proc, 1, key);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HTuple result;
			num = HTuple.LoadNew(proc, 0, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}

		/// <summary>
		///   Read a dictionary from a file.
		///   Modified instance represents: Dictionary handle.
		/// </summary>
		/// <param name="fileName">File name.</param>
		/// <param name="genParamName">Name of the generic parameter. Default: []</param>
		/// <param name="genParamValue">Value of the generic parameter. Default: []</param>
		// Token: 0x06000489 RID: 1161 RVA: 0x0001B670 File Offset: 0x00019870
		public void ReadDict(string fileName, HTuple genParamName, HTuple genParamValue)
		{
			this.Dispose();
			IntPtr proc = HalconAPI.PreCall(2162);
			HalconAPI.StoreS(proc, 0, fileName);
			HalconAPI.Store(proc, 1, genParamName);
			HalconAPI.Store(proc, 2, genParamValue);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(genParamName);
			HalconAPI.UnpinTuple(genParamValue);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Read a dictionary from a file.
		///   Modified instance represents: Dictionary handle.
		/// </summary>
		/// <param name="fileName">File name.</param>
		/// <param name="genParamName">Name of the generic parameter. Default: []</param>
		/// <param name="genParamValue">Value of the generic parameter. Default: []</param>
		// Token: 0x0600048A RID: 1162 RVA: 0x0001B6D8 File Offset: 0x000198D8
		public void ReadDict(string fileName, string genParamName, string genParamValue)
		{
			this.Dispose();
			IntPtr proc = HalconAPI.PreCall(2162);
			HalconAPI.StoreS(proc, 0, fileName);
			HalconAPI.StoreS(proc, 1, genParamName);
			HalconAPI.StoreS(proc, 2, genParamValue);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Remove keys from a dictionary.
		///   Instance represents: Dictionary handle.
		/// </summary>
		/// <param name="key">Key to remove.</param>
		// Token: 0x0600048B RID: 1163 RVA: 0x0001B734 File Offset: 0x00019934
		public void RemoveDictKey(HTuple key)
		{
			IntPtr proc = HalconAPI.PreCall(2165);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, key);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(key);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Remove keys from a dictionary.
		///   Instance represents: Dictionary handle.
		/// </summary>
		/// <param name="key">Key to remove.</param>
		// Token: 0x0600048C RID: 1164 RVA: 0x0001B778 File Offset: 0x00019978
		public void RemoveDictKey(string key)
		{
			IntPtr proc = HalconAPI.PreCall(2165);
			base.Store(proc, 0);
			HalconAPI.StoreS(proc, 1, key);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Add a key/object pair to the dictionary.
		///   Instance represents: Dictionary handle.
		/// </summary>
		/// <param name="objectVal">Object to be associated with the key.</param>
		/// <param name="key">Key string.</param>
		// Token: 0x0600048D RID: 1165 RVA: 0x0001B7B4 File Offset: 0x000199B4
		public void SetDictObject(HObject objectVal, HTuple key)
		{
			IntPtr proc = HalconAPI.PreCall(2169);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, objectVal);
			HalconAPI.Store(proc, 1, key);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(key);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
			GC.KeepAlive(objectVal);
		}

		/// <summary>
		///   Add a key/object pair to the dictionary.
		///   Instance represents: Dictionary handle.
		/// </summary>
		/// <param name="objectVal">Object to be associated with the key.</param>
		/// <param name="key">Key string.</param>
		// Token: 0x0600048E RID: 1166 RVA: 0x0001B804 File Offset: 0x00019A04
		public void SetDictObject(HObject objectVal, string key)
		{
			IntPtr proc = HalconAPI.PreCall(2169);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, objectVal);
			HalconAPI.StoreS(proc, 1, key);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
			GC.KeepAlive(objectVal);
		}

		/// <summary>
		///   Add a key/tuple pair to the dictionary.
		///   Instance represents: Dictionary handle.
		/// </summary>
		/// <param name="key">Key string.</param>
		/// <param name="tuple">Tuple value to be associated with the key.</param>
		// Token: 0x0600048F RID: 1167 RVA: 0x0001B850 File Offset: 0x00019A50
		public void SetDictTuple(HTuple key, HTuple tuple)
		{
			IntPtr proc = HalconAPI.PreCall(2170);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, key);
			HalconAPI.Store(proc, 2, tuple);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(key);
			HalconAPI.UnpinTuple(tuple);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Add a key/tuple pair to the dictionary.
		///   Instance represents: Dictionary handle.
		/// </summary>
		/// <param name="key">Key string.</param>
		/// <param name="tuple">Tuple value to be associated with the key.</param>
		// Token: 0x06000490 RID: 1168 RVA: 0x0001B8A0 File Offset: 0x00019AA0
		public void SetDictTuple(string key, HTuple tuple)
		{
			IntPtr proc = HalconAPI.PreCall(2170);
			base.Store(proc, 0);
			HalconAPI.StoreS(proc, 1, key);
			HalconAPI.Store(proc, 2, tuple);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(tuple);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Write a dictionary to a file.
		///   Instance represents: Dictionary handle.
		/// </summary>
		/// <param name="fileName">File name.</param>
		/// <param name="genParamName">Name of the generic parameter. Default: []</param>
		/// <param name="genParamValue">Value of the generic parameter. Default: []</param>
		// Token: 0x06000491 RID: 1169 RVA: 0x0001B8EC File Offset: 0x00019AEC
		public void WriteDict(string fileName, HTuple genParamName, HTuple genParamValue)
		{
			IntPtr proc = HalconAPI.PreCall(2173);
			base.Store(proc, 0);
			HalconAPI.StoreS(proc, 1, fileName);
			HalconAPI.Store(proc, 2, genParamName);
			HalconAPI.Store(proc, 3, genParamValue);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(genParamName);
			HalconAPI.UnpinTuple(genParamValue);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Write a dictionary to a file.
		///   Instance represents: Dictionary handle.
		/// </summary>
		/// <param name="fileName">File name.</param>
		/// <param name="genParamName">Name of the generic parameter. Default: []</param>
		/// <param name="genParamValue">Value of the generic parameter. Default: []</param>
		// Token: 0x06000492 RID: 1170 RVA: 0x0001B944 File Offset: 0x00019B44
		public void WriteDict(string fileName, string genParamName, string genParamValue)
		{
			IntPtr proc = HalconAPI.PreCall(2173);
			base.Store(proc, 0);
			HalconAPI.StoreS(proc, 1, fileName);
			HalconAPI.StoreS(proc, 2, genParamName);
			HalconAPI.StoreS(proc, 3, genParamValue);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}
	}
}
